package ar.edu.unlu.sistemas.p2p.business.msg;

import org.jdom.Document;
import org.jdom.Element;

public class QueryMessage extends Message {
	
	private String query;
	private String transferMode;
	public static final String TAG_QUERY = "query";
	//public static final String TAG_TRANSF_MODE = "tmode";
	
	public String getTransferMode() {
		return transferMode;
	}

	public void setTransferMode(String transferMode) {
		this.transferMode = transferMode;
	}
	
	public String getQuery() {
		return query;
	}

	public void setQuery(String query) {
		this.query = query;
	}

	public QueryMessage(Document xmlDoc) {
		super(xmlDoc);
		// TODO Auto-generated constructor stub
	}

	public QueryMessage(int type) {
		super(type);
		// TODO Auto-generated constructor stub
	}

	public QueryMessage(String msgId, int type) {
		super(msgId, type);
		// TODO Auto-generated constructor stub
	}
	
	public QueryMessage() {
		super(MessageFactory.CODE_QUERY);
	}
	
	public Element toXMLElement() {
		Element root = super.toXMLElement();
		root.addContent(new Element(TAG_QUERY).setText(String.valueOf(this.getQuery())));
		//root.addContent(new Element(TAG_TRANSF_MODE).setText(String.valueOf(this.getTransferMode())));
		return root;
	}
	
	protected Element buildFromXMLDoc(Document xmlDoc) {
		Element root = super.buildFromXMLDoc(xmlDoc);
		this.setQuery(root.getChildText(TAG_QUERY));
		//this.setTransferMode(root.getChildText(TAG_TRANSF_MODE));
		return root;
	}

}
